package logic

import (
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddressDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddressDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressDelLogic {
	return &AddressDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 地址删除
func (l *AddressDelLogic) AddressDel(in *user.AddressDelRequest) (*user.AddressDelResponse, error) {
	err := dao.AddressDel(int(in.AddressId))
	if err != nil {
		pkg.Error("地址删除失败", zap.Error(err))
		return nil, err
	}

	return &user.AddressDelResponse{Msg: "地址删除成功"}, nil
}
